import lib.resolver.TxtDisplay;

var txtResolver;
var blockMin;

function resolve(target:MovieClip, resource, param, operation:String)
{
	// trace("target: "+target);
	// trace("operation: "+operation);
	// trace("resource: "+resource);
	// trace("param: "+param);
	trace("txtReaderResolver was called..."+txtResolver+" "+operation);
	if (txtResolver==null)
	{
		var playArea=mlf.gatekeeper.native.Caller.scanElement("Player", "txtReader");
		
		target.beginFill(0x0000ff, 0);
		target.moveTo(0, 0);
		target.lineTo(playArea._width, 0);
		target.lineTo(playArea._width, playArea._height);
		target.lineTo(0, playArea._height);
		target.lineTo(0, 0);
		target.endFill();
		// trace(target._width+" "+target._height);
		txtResolver=new TxtDisplay(target, mlf.mcmanager.MessageAgent.getMessageDispatcher());
		txtResolver.content=resource.toString();
	}

	if (operation=="play")
	{
		// txtResolver.content=resource.toString();
		// trace("txtResolver.play......"+blockMin);
		 txtResolver.scanBlocks(blockMin);
		// txtResolver.createDisplayTextField();
		 txtResolver.switchBlock(null, 0);
	}
	else if (operation=="close")
	{
		// trace(this+".close...");
		txtResolver.close();
		delete txtResolver;
	}
}

function onTxtInit(obj:Object)
{
	// trace("onTxtInit......"+obj.param);
	mlf.mcmanager.MessageAgent.getMessageDispatcher().removeEventListener("onTxtInit", this);
	blockMin=obj.param;
	// txtResolver.scanBlocks(obj.param);
	// txtResolver.switchBlock(null, 0);
}

mlf.mcmanager.MessageAgent.getMessageDispatcher().addEventListener("onTxtInit", this);